<style type="text/css">
    .table th {
        text-align: center;
        vertical-align: middle!important;
    }
    .table th:nth-child(1), 
    .table td:nth-child(1){
        width: 7%;
    } 
    .table th:nth-child(2), 
    .table td:nth-child(2){
        width: 20%;
    } 
    .table th:nth-child(3), 
    .table td:nth-child(3) {
        width: 57%;
    }
    .table th:nth-child(4), 
    .table td:nth-child(4) {
        width: 15%;
    }
    .pagination li {
        display: inline;
        margin-left: 0.5em;
        margin-right: 0.5em;
    }
    .red {color: red;}
</style>
<div class="row" style="margin-top: 20px">
    <div class="col-md-1">
        <a href="{{url('ql=themchucvu')}}" class="btn btn-primary pull-right"><i class="glyphicon glyphicon-plus"></i>&nbsp;Thêm mới</a>&nbsp;
        <!--Kết thúc chức vụ-->
    </div>
    <div class="col-md-11">
        <!--Bảng danh sách chức vụ-->
        <table id="data-table" class="table table-striped table-bordered" cellspacing="0" width="100%">
            <thead>
                <tr  class="label-warning">
                    <th>STT</th>
                    <th>Mã chức vụ</th>
                    <th>Tên chức vụ</th>
                    <th>Tác vụ</th>
                </tr>
            </thead>
            <tbody>
                @foreach($data as $row)
                @if ($row != null)
                <tr>
                    <td class="text-center">{{++$numRows}}</td>
                    <td class="text-center">{{$row->MA_CV}}</td>
                    <td>{{$row->TEN_CV}}</td>
                    <td class="text-center">
                        <a href="{{url('view=dschucvu')}}" id="{{$row->ID}}" class="details_cv text-success btn btn-sm btn-success"><i class="glyphicon glyphicon-search" title="Xem chi tiết"></i></a>&nbsp;
                        <a href="{{url('delete=dschucvu')}}" id="{{$row->ID}}" class="delete_cv text-danger btn btn-sm btn-danger" title="Xóa chức vụ"><i class="glyphicon glyphicon-remove"></i></a>
                    </td>
                </tr>
                @endif
                @endforeach
            </tbody>
        </table>
        <!--Kết thúc bảng danh sách chức vụ-->
    </div>
</div>
<script>
    $(".details_cv").on("click", function (e) {
            var id = $(this).attr("id");
            var url = $(this).attr('href');
            location.href = url + "?id=" + id;
            return false;
        });
    $(".delete_cv").on("click", function (e) {
            var id = $(this).attr("id");
            var tencv = $("#tencv_" + id).text();
            if (confirm("Xác nhận xóa chức vụ " + tencv + " ?"))
            {
                var url = $(this).attr('href');
                url += "?id=" + id;
                var pathname = window.location.href;
                var result = pathname.split('?');
                if (result[1] !== "undefined")
                {
                    url += "&" + result[1];
                }
                location.href = url;
            }
            return false;
        });
</script>
@if (Session::has('warning'))
<script type="text/javascript">
    toastr.warning('{{Session::get('warning')}}');</script>
@endif
@if (Session::has('error'))
<script type="text/javascript">
            toastr.error('{{Session::get('error')}}');
</script>
@endif
@if (Session::has('success'))
<script type="text/javascript">
    toastr.success('{{Session::get('success')}}');</script>
@endif
